import 'package:flutter/material.dart';
import 'package:flutter_app/pages/home/info/info_item.dart';

class CommonFormItemField extends StatelessWidget {
  const CommonFormItemField({
    Key? key,
    required this.lable,
    this.suffix,
    this.hintText,
    this.controller,
    this.contentBuilder,
    this.suffixText,
  }) : super(key: key);
  final String lable;
  final Widget? suffix;
  final String? suffixText;
  final String? hintText;
  final TextEditingController? controller;
  final Widget Function(BuildContext context)? contentBuilder;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: const BoxDecoration(
          border: Border(bottom: BorderSide(color: Colors.grey))),
      child: Row(
        children: [
          Container(
            padding: const EdgeInsets.only(left: 10, bottom: 10, top: 10),
            child: Text(
              lable,
              style: const TextStyle(fontSize: 16),
            ),
            width: 100,
          ),
          contentBuilder != null
              ? contentBuilder!(context)
              : Expanded(
                  child: TextField(
                  controller: controller,
                  decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: hintText,
                  ),
                )),
          if (suffix != null)
            Padding(padding: const EdgeInsets.only(right: 10), child: suffix!),
          if (suffix == null && suffixText != null)
            Padding(
              padding: const EdgeInsets.only(right: 10),
              child: Text(suffixText!),
            ),
        ],
      ),
    );
  }
}
